/*
** writen by hanv
** n2.vietha@gmail.com
*/
package vn.vng.research.fsd.services.threads;

import org.apache.thrift.server.TServer;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.transport.TServerSocket;
import org.apache.thrift.transport.TServerTransport;
import org.apache.thrift.transport.TTransportException;

import vn.vng.research.fsd.Configuration;
import vn.vng.research.fsd.services.SearchServiceHandle;
import vn.vng.research.fsd.services.thrift.SearchService;



public class SearchServiceThread extends Thread {

	@Override
	public void run() {
		// TODO Auto-generated method stub
		try {
            //TNonblockingServerSocket socket = new TNonblockingServerSocket(Configuration.loadPort("search"));
            SearchService.Processor processor = new SearchService.Processor(new SearchServiceHandle());
            //THsHaServer.Options options = new THsHaServer.Options();
            //options.workerThreads = 10;
            
            //multithreaded
            TServerTransport serverTransport = new TServerSocket(Configuration.loadPort("search"));
            //server = new THsHaServer(new TProcessorFactory(processor), socket, new TFramedTransport.Factory(), new TBinaryProtocol.Factory(), options);
            server = new TThreadPoolServer(new TThreadPoolServer.Args(serverTransport).processor(processor));
            System.out.println("    Starting server on port "+Configuration.loadPort("search")+" ...");
            server.serve();

        } catch (TTransportException e) {
            e.printStackTrace();
        }
    }
    private TServer server;

	
}
